#ifndef _TIMER_H_
#define _TIMER_H_


#include "linklist.h"


/* timer mode */
enum TIMER_TYPE {
	TIMER_TYPE_ONETIME,
	TIMER_TYPE_OVERLOAD,
};

/* timer status */
enum TIMER_STATUS {
	TIMER_STATUS_RUNNING,
	TIMER_STATUS_PAUSE,
	TIMER_STATUS_STOP,
};

/* timer struct */
typedef struct {
	enum TIMER_TYPE	type;
	enum TIMER_STATUS status;
	unsigned int start_tick;
	unsigned int mark_tick;
	unsigned int interval;
	unsigned int over_times;	
	void (*timeup_callback)(unsigned int);
	struct list_head link_node;
} timer_t;


extern timer_t *timer_create(enum TIMER_TYPE t, unsigned int interval, void (*callback)(unsigned int));
extern int timer_start(timer_t *timer);
extern int timer_resume(timer_t *timer);
extern int timer_pause(timer_t *timer);
extern int timer_stop(timer_t *timer);
extern int timer_delete(timer_t *timer);
extern int timer_delay(int wtick);
extern unsigned int timer_get_systick(timer_t *timer);


#endif /* ifndef _TIMER_H_ */
